

<%@page import="com.ykwep.web.server.data.Page"%><jsp:include page="/header.jsp" />

		
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="com.ykwep.web.server.PMF"%>
<%@page import="com.ykwep.web.server.data.NewsItem"%>
<%@page import="java.util.List"%>		
		
		<h2>Add a Page</h2>
			<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
	<script src="/ckeditor/_samples/sample.js" type="text/javascript"></script>
		
		
	<form action="/admin/add_page" method="post">
		  <div>Name:<br/> <input name="name"></input> (Must be a valid part of an URL e.g. home)</div>
	  <div>Title:<br/> <input name="title"></input></div>
      	  <div>Publish:<br/> <input name="published" type="checkbox" checked></input></div>
      
      <div>Content:<br/> <textarea cols="75" id="editor1" name="content" rows="20"></textarea></div>
      		<script type="text/javascript">
				//<![CDATA[

					// This call can be placed at any point after the
					// <textarea>, or inside a <head><script> in a
					// window.onload event handler.

					// Replace the <textarea id="editor"> with an CKEditor
					// instance, using default configurations.
					CKEDITOR.replace( 'editor1' );

				//]]>
				</script>
      <div><input type="submit" value="Post" /></div>
    </form>
   
    
		
		<h2>Pages</h2>
		<%
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "select from " + Page.class.getName();
    List<Page> newsItems = (List<Page>) pm.newQuery(query).execute();
    if (newsItems.isEmpty()) {
%>

<p>There are no pages.</p>
<%
    } else {
        for (Page g : newsItems) {
%>
		<%=g.getName() %> <%= g.getDate() %> <a href="/admin/edit_page.jsp?page_id=<%= g.getId() %>">Edit page</a> | <a href="/admin/delete_page?page_id=<%= g.getId() %>&delete=true">Delete page</a><br/>     
		Link to page: <i>&lt;a href="/show_page.jsp?page_name=<%= g.getName() %>"&gt;<%=g.getTitle() %>&lt;/a&gt;</i><br/> 
		
		<%    }
    }
    pm.close();
%>
		
 <h2>Help</h2>
 <p>There are some page names with special properties.</p>
 
 <ul>
  <li> home - A page with this name will be displayed on /index.jsp with news under the content </li>
  <li> top_menu - Contains the content in the top menu<br/>
  <i>Example:<br/>
        &lt;ul&gt;<br/>
			&lt;li>&lt;a href="/first_page_loc">Home&lt;/a&gt;&lt;/li&gt;<br/>
			&lt;li>&lt;a href="/second_page_loc">Contact&lt;/a&gt;&lt;/li&gt;<br/>
		&lt;/ul&gt;</i></li>
</ul>

				
<jsp:include page="/footer.jsp" />
				